package com.dingup.mock.bean.exam;

import com.dingup.mock.enums.ExamContentTypeEnum;
import com.dingup.mock.enums.ExamTypeEnum;
import com.dingup.mock.bean.listening.ExamListeningInfo;
import com.dingup.mock.bean.reading.ExamReadingInfo;
import com.dingup.mock.bean.speaking.ExamSpeakingInfo;
import com.dingup.mock.bean.writing.ExamWritingInfo;
import com.dingup.util.GDateUtil;
import com.dingup.util.GStrUtil;

import java.io.Serializable;
import java.util.Date;

import static com.dingup.util.GConstUtil.STRING_EMPTY;

/**
 * Created by yanggavin on 16/3/16.
 */
public class ExaminationInfo implements Serializable {
    private static final long serialVersionUID = -2162050638791224341L;
    /**
     * 考试Id,自动生成的唯一Id
     */
    private String id;
    private ExamTypeEnum examType;
    private String userId;
    private String userAccount;
    private Date beginTime;
    private Date endTime;
    private String subjectName;
    /**
     * 最后更新时间,用于跟踪缓存状态
     */
    private Date lastUpdateTime;
    private Integer homeworkRecordId;
    private Integer homeworkQuestionNum;
    private Integer homeworkId;
    /**
     * 考试项目类型:听/说/读/写/全部
     */
    private ExamContentTypeEnum examContentType;
    /**
     * 阅读部分
     */
    private ExamReadingInfo examReadingInfo;
    /**
     * 听力部分
     */
    private ExamListeningInfo examListeningInfo;
    /**
     * 口语部分
     */
    private ExamSpeakingInfo examSpeakingInfo;
    /**
     * 写作部分
     */
    private ExamWritingInfo examWritingInfo;
    /**
     * 答题进度字符串
     * 形如:READING - 1-1 - 12:12:12
     */
    private String curAnswerProcess;

    public ExaminationInfo(){
        id = String.format("exam%s%s", GDateUtil.getCurShortDateStr(), GStrUtil.getRandomStr(4)).toLowerCase();
        userId = STRING_EMPTY;
        examType = ExamTypeEnum.PRACTICE;
        beginTime = new Date();
        endTime = new Date();
        examContentType = ExamContentTypeEnum.DEFAULT;
        examReadingInfo = null;
        examListeningInfo = null;
        examSpeakingInfo = null;
        examWritingInfo = null;
        curAnswerProcess = "";
        lastUpdateTime = new Date();
        homeworkRecordId = 0;
        homeworkQuestionNum = 0;
        homeworkId = 0;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public ExamTypeEnum getExamType() {
        return examType;
    }

    public void setExamType(ExamTypeEnum examType) {
        this.examType = examType;
    }

    public ExamContentTypeEnum getExamContentType() {
        return examContentType;
    }

    public void setExamContentType(ExamContentTypeEnum examContentType) {
        this.examContentType = examContentType;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public ExamReadingInfo getExamReadingInfo() {
        return examReadingInfo;
    }

    public void setExamReadingInfo(ExamReadingInfo examReadingInfo) {
        this.examReadingInfo = examReadingInfo;
    }

    public ExamListeningInfo getExamListeningInfo() {
        return examListeningInfo;
    }

    public void setExamListeningInfo(ExamListeningInfo examListeningInfo) {
        this.examListeningInfo = examListeningInfo;
    }

    public ExamSpeakingInfo getExamSpeakingInfo() {
        return examSpeakingInfo;
    }

    public void setExamSpeakingInfo(ExamSpeakingInfo examSpeakingInfo) {
        this.examSpeakingInfo = examSpeakingInfo;
    }

    public ExamWritingInfo getExamWritingInfo() {
        return examWritingInfo;
    }

    public void setExamWritingInfo(ExamWritingInfo examWritingInfo) {
        this.examWritingInfo = examWritingInfo;
    }

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getCurAnswerProcess() {
        return curAnswerProcess;
    }

    public void setCurAnswerProcess(ExamContentTypeEnum type, String questionDes) {
        curAnswerProcess = String.format("%s | %s | %s", type.getCode().toUpperCase(), questionDes, GDateUtil.getOnlyTimeStr(new Date()));
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public void setCurAnswerProcess(String curAnswerProcess) {
        this.curAnswerProcess = curAnswerProcess;
    }

    public Integer getHomeworkRecordId() {
        return homeworkRecordId;
    }

    public void setHomeworkRecordId(Integer homeworkRecordId) {
        this.homeworkRecordId = homeworkRecordId;
    }

    public Integer getHomeworkQuestionNum() {
        return homeworkQuestionNum;
    }

    public void setHomeworkQuestionNum(Integer homeworkQuestionNum) {
        this.homeworkQuestionNum = homeworkQuestionNum;
    }

    public Integer getHomeworkId() {
        return homeworkId;
    }

    public void setHomeworkId(Integer homeworkId) {
        this.homeworkId = homeworkId;
    }

    public String getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(String userAccount) {
        this.userAccount = userAccount;
    }
}
